package com.rbs.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@MapperScan("com.rbs.mapper")
public class MybatisPlusConfig implements WebMvcConfigurer {
    /**
     * 添加分页插件
     */

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        //1.核心插件
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //2.添加分页插件
        PaginationInnerInterceptor pageInterceptor=new PaginationInnerInterceptor(DbType.MYSQL);
        //pageInterceptor.setMaxLimit(1000L);//设置分页上限，避免一次查询太多，服务器负载过大。暂时不考虑
        interceptor.addInnerInterceptor(pageInterceptor);
        return interceptor;
    }
}
